/**
 * 预定
 * Created by Administrator on 2017/10/4 0004.
 */
(function ($j) {
    function init() {
        renderData();
        bindBtnEvent();
    };

    function renderData() {

    };

    function bindBtnEvent() {
        //点击预定按钮
        $('.doReserve').off('click').on('click', function () {
            $('#warning').html('');
            var radio = $("input[name='my-radio']:checked").val();
            if (radio == undefined) {
                $('#warning').html('<span class="iconfont icon-cuowu" style="margin-right:5px"></span>请选择一种产品进行预定');
            } else {
                //获得用户信息
                $j.restPost('/user/doGetUserInfo').done(function (mess, data) {
                    if (data.nickName == undefined) {
                        $.modal({
                            title: '提示',
                            text: '请先完善您的身份信息',
                            buttons: [
                                {
                                    text: '立即完善',
                                    onClick: function () {
                                        window.location.href = "/user/user_info";
                                    }
                                }
                            ]
                        });
                    } else {
                        $j.restPost('/order/doReserve', {
                            deviceId: radio,
                            type:'未安装',
                            params:'安装'
                        }).done(function (mess, data) {
                            $.alert('已经预定成功,工作人员会很快与您联系');
                        }).fail(function (mess) {
                            $.toast(mess);
                        })
                    }
                }).fail(function (mess) {
                    $.toast(mess);
                });
            }
        });
    }

    init();
})(jQuery)
